<!DOCTYPE html>
<html>

<head>
    {include file="Public/header"}

</head>

<body class="gray-bg" style="color:#333;padding:3px;">
<div class="ibox">
    <div class="ibox-title"><a href="{:url('tinetgroup/index')}?jxs_id={:request()->get('jxs_id')}"  class="J_menuItem" title="常用网点分组">管理常用网点分组</a></div>
    <div class="ibox-content">
        <table class="table table-bordered table-striped">
            <tr>
                <th style="width:20%;">分组名</th>
                <th>包含网点</th>
                <th style="width:20%;">选择</th>
            </tr>
            {volist name="data" id="row"}
            <tr>
                <td>{$row.title}</td>
                <td>{$row.net_title}</td>
                <td><button class="btn btn-primary xuanze" data-net_json='{$row.net_json}'>选择</button></td>
            </tr>
            {/volist}
        </table>
    </div>
</div>
<!-- 全局js -->
{include file="Public/footer"}
<script src="__STATIC__/layout/js/contabs_sub.js"></script>
<script>
$(function () {

    //选择某一个分组
    $('.xuanze').on('click',function () {
        var net_json = $(this).data('net_json')
//        net_json = JSON.parse(net_json)
        var inarr = []
        parent.$('#selected_net .ren').each(function (i,o) {
            inarr.push($(o).data('id'))
        })
        for(var i=0;i<net_json.length;i++){
            if(-1==$.inArray(net_json[i].id,inarr)){
                parent.$('#selected_net').append('<span class="ren" data-id="'+net_json[i].id+'">'+net_json[i].title+'<span class="close">×</span></span>')
                $.ajax({
                    type:'post',
                    url:'{:url("chaTiaoMa")}',
                    data:{id:net_json[i].id},
                    success:function (data) {
                        parent.$('#yiJinChangTiaoMa').append(data.tiaoMaShu)
                    },
                    dataType:'json',
                    async:false
                })
            }
        }

        $.ajax({
            type:'post',
            url:'{:url("benCiJinChangTiaoMa")}',
            async:false,
            data:{data:inarr},
            success:function (data) {
                parent.$('#benCiJinChangTiaoMa').parent().find('.cg_suggest').html(data)
            }})

        parent.layer.close(parent.layer.getFrameIndex(window.name))
    })
})
$('.J_menuItem').on('click', menuItem);
</script>
</body>

</html>
